<%@page language="java" pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ taglib prefix="sj" uri="/struts-jquery-tags"%>
	<script language="javascript">
		$(function() {
			$("#datepicker1").datepicker( $.datepicker.regional[ "es" ] );
			$("#datepicker2").datepicker( $.datepicker.regional[ "es" ] );
			$("#tareaForm").validate(); 
		});
	</script>
	<script>
  		$("#tareaForm").submit(function(event) {
    		event.preventDefault(); 
    		$('#agregarTareaDialog').dialog('close');
    		/* Send the data using post and put the results in a div */
	    	$('#tabla_tareas').html('<img alt="Loading..." src="../img/ajaxLoader.gif" />');
	    	$.post("../tareas/tareaGuardar", $("#tareaForm").serialize(),
	      		function( data ) {
	    			$('#tabla_tareas').html(data);
				});
			$('#tablaTareas').dataTable();
			return false;
		});
	</script>
	
	<script type="text/javascript">
		function cancelButton() { $('#agregarTareaDialog').dialog('close'); return false; };
	    function saveButton() { $('#tareaForm').submit(); };
	</script>
	
	<s:actionerror />
	<s:actionmessage />
	<s:form id="tareaForm" action="tareaGuardar" method="post">
		<table>
		 	<tr>
				<td>Descripción</td>
				<td><s:textarea name="tarea.descripcion" theme="simple" cssClass="required" cols="25" rows="2" /></td>
			</tr>
			<s:if test="tarea.idTarea != null">
				<tr>
					<td>Estado</td>
					<td><s:select list="estadosTarea" theme="simple" listKey="idEstadoTarea" listValue="nombre" headerKey="-1"
					headerValue="-- Seleccione el Estado de la Tarea --" name="tarea.estadoTarea.idEstadoTarea" 
					value="tarea.estadoTarea.idEstadoTarea"></s:select></td>
				</tr>
			</s:if>
			<tr>
				<td>Tipo de Tarea</td>
				<td><s:select list="tiposTarea" theme="simple" listKey="idTipoTarea" listValue="nombre" headerKey="-1"
				headerValue="-- Seleccione el Tipo de Tarea --" name="tarea.tipoTarea.idTipoTarea"></s:select></td>
			</tr>
			<tr>
				<td>Fecha de Inicio</td>
				<td><s:textfield name="tarea.fechaDesde" theme="simple" cssClass="required" id="datepicker1"/></td>
			</tr>
			<tr>
				<td>Fecha de finalizacion</td>
				<td><s:textfield name="tarea.fechaHasta" theme="simple" cssClass="required" id="datepicker2"/></td>
			</tr>
			
			<tr>
				<td>Horas Asignadas</td>
				<td> <s:textfield name="tarea.horasAsignadas" theme="simple" size="5"/></td>
			</tr>
		</table>
		<s:hidden name="tarea.proyecto.idProyecto"></s:hidden>
		<s:hidden name="tarea.idTarea"></s:hidden>
	</s:form>